import java.util.Scanner;
import java.util.Random;
public class Test {
    public static void main10(String[] args) { //输出0~999的所有水仙花数
        for (int i = 100; i < 1000; i++) {
            int g=i%10;
            int s=i/10%10;
            int b=i/100%10;
            if(i==(int)(Math.pow(g,3)+Math.pow(s,3)+Math.pow(b,3))){
                System.out.println(i+"是水仙花数");
            }
        }
    }
    public static void main9(String[] args) { //输出1000到2000的闰年
        for (int i = 1000; i <= 2000; i++) {
            if(i%400==0){
                System.out.println(i+"是世纪闰年");
            }else if(i%4==0 && i%100 != 0){
                System.out.println(i+"是普通闰年");
            }else{
                System.out.println(i+"不是闰年");
            }
        }
    }
    public static void main8(String[] args) { //打印1-100之间的素数
        for (int i = 2; i <=100 ; i++) {
            int flag = 1;
            for ( int j = 2; j <=i/2 ; j++) {
                if(i%j==0){
                    System.out.println(i+"不是素数");
                    flag=0;
                    break;
                }
            }
            if(flag==1){
                System.out.println(i+"是素数");
            }
        }
    }
    public static void main7(String[] args) { //判断年龄
        Scanner scanner = new Scanner(System.in);
        int age=scanner.nextInt();
        if(age<=18 && age>0){
            System.out.println("少年");
        }else if(age>=19 && age<=28) {
            System.out.println("青年");
        } else if (age>=29 && age<=55) {
            System.out.println("中年");
        } else if (age>=56) {
            System.out.println("老年");
        }
    }
    public static void main6(String[] args) { //打印9*9乘法口诀表
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j+" * "+i+" = "+i*j+"\t");
                //System.out.printf("%d * %d = %d\t",j,i,j*i);
            }
            System.out.print("\n");
        }
    }
    public static void main5(String[] args) { //模拟登录  三次机会
        Scanner scanner=new Scanner(System.in);
        String key = "123456";
        int count =3;
        while(count != 0){
            System.out.println("请输入密码> ");
            String password = scanner.nextLine();
            if(key.equals(password)){
                System.out.println("登录成功");
                break;
            }else{
                count--;
                System.out.println("密码错误，剩余"+count+"机会。");
            }
        }
    }
    public static void main4(String[] args) { //打印X图案
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int i=0;
            for(i=0;i<a;i++){
                int j=0;
                for(j=0;j<a;j++){
                    if(i==j||(i+j)==(a-1)){
                        System.out.print('*');
                    }
                    else{
                        System.out.print(' ');
                    }
                }
                System.out.print('\n');
            }
        }
    }
    public static void main3(String[] args) { //计算分数的值
        //Scanner scanner = new Scanner (System.in);
        double sum=0;
        int flag=1;
        for (int i = 1; i < 101; i++) {
            sum+=flag*(1.0/i);
            flag=(-1)*flag;
        }
        System.out.println(sum);
    }
    public static void main2(String[] args) { //求两个数的最大公约数方法二：辗转相除法
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入两个整数：");
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        int a=m;
        int b=n;
        int t=m%n;
        while(t!=0){
            m=n;
            n=t;
            t=m%n;
        }
        System.out.println(a+"和"+b+"的最大公约数为："+n);
    }
    public static void main1(String[] args) {//求两个数的最大公约数方法一：穷举法
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入两个整数：");
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        int max = m < n ? m : n;
        int i=0;
        for ( i = max; i > 0; i--) {
            if(m % i == 0 && n % i ==0) {
                break;
            }
        }
        System.out.println(m+"和"+n+"的最大公约数为："+i);
    }
    public static void main0(String[] args) {
        Random random = new Random(); // 默认随机种子是系统时间
        Scanner sc = new Scanner(System.in);
        int toGuess = random.nextInt(100);
// System.out.println("toGuess: " + toGuess);
        while (true) {
            System.out.println("请输入要输入的数字: (1-100)");
            int num = sc.nextInt();
            if (num < toGuess) {
                System.out.println("低了");
            } else if (num > toGuess) {
                System.out.println("高了");
            } else {
                System.out.println("猜对了");
                break;
            }
        }
    }
    public static void main11(String[] args) { //计算一个数中二级制位的个数
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数");
        int n = scanner.nextInt();
        int count = 0;
        for (int i = 0; i < 32; i++) {
            if(((n>>i)&1)==1) {
                count++;
            }
        }
        System.out.println(n+"二进制中有"+count+"个1");
    }
    public static void main(String[] args) { //获取一个数二进制序列中所有的偶数位和奇数位，分别输出二进制序列。
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数");
        int n=scanner.nextInt();
        for (int i = 30; i >=0; i-=2) { //从左往右打印  偶数位
            System.out.print((n>>i)&1);
        }
        System.out.print('\n');
        for (int i = 31; i >=1 ; i-=2) { // 奇数位
            System.out.print((n>>i)&1);
        }
    }
}
